package com.wxp.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 程序启动入口
 * //@EnableBinding(Source.class)：指向配置⽂件的output参数
 * //@EnableBinding(Sink.class)：指向配置⽂件的input参数
 *
 * @author wxp
 */
@EnableDiscoveryClient
@EnableBinding({Source.class, Sink.class})
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class ServiceStreamApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(ServiceStreamApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        System.out.println("\n----------------------------------------------------------\n\t" +
                "Application wxp-io is running! Access URLs:\n\t" +
                "Local:\t\thttp://localhost:" + port + path + "/\n\t" +
                "External:\thttp://" + ip + ":" + port + path + "/\n\t" +
                "Swagger文档:\thttp://" + ip + ":" + port + path + "/doc.html\n\t" +
                "----------------------------------------------------------");
    }
}